
#![no_std]
#![no_main]


use panic_halt as _;

use stm32f1xx_hal::pac;

use stm32f1xx_hal::prelude::{
    _stm32_hal_flash_FlashExt, _stm32_hal_rcc_RccExt, _fugit_RateExtU32,
    _stm32_hal_gpio_GpioExt,
};

use cortex_m::asm;

use fire_rs::single_led::{
    LED, LedCommomAnode, Pin2Led
};


#[cortex_m_rt::entry]
fn main() -> ! {

    let dp = pac::Peripherals::take().unwrap();

    let rcc = dp.RCC.constrain();
    let mut flash = dp.FLASH.constrain();

    rcc.cfgr.use_hse(8.MHz()).sysclk(72.MHz()).freeze(&mut flash.acr);

    let mut gpiob = dp.GPIOB.split();
    let mut led = gpiob.pb0.into_push_pull_output(&mut gpiob.crl).to_led(LedCommomAnode);
    let mut led1 = gpiob.pb1.into_push_pull_output(&mut gpiob.crl).to_led(LedCommomAnode);

    // led.turn_off();
    // led1.turn_on();    

    led.turn_off();
    led1.turn_off();

    loop {
        led.toggle();
        for _ in 0..10 {
            asm::delay(1_000_000);
        }
        led.toggle();
        for _ in 0..10 {
            asm::delay(1_000_000);
        }
    }
}
